checkLogin();

var province_id = 0;
var city_id = 0;
var area_id = 0;
var to_addDetail = 0;
var ref = parseInt(GetQueryString('ref'));
var range_in = null;

var region = ''; //搜索地址时
//验证表单并处理登录交互
var ajaxOption = {
    url: address_add,
    method: 'POST',
    data:comParams(),
    success: function (res) {
        setTimeout(function () {
            if (ref) {
                // 1.零售订水  2.水票订水
                if (ref == 1) {
                    locationReplace('pay-order.html');
                }
                if (ref == 2) {
                    locationReplace('member-ticket.html');
                }
                if(ref == 3){
                    locationReplace('water-index.html')
                }

            } else {
                locationReplace('address.html');
            }
        },2000);
    }
};

var is_mobile = function(e) {
    var status = true;
    if (!(/^1\d{10}$/.test( $(e).val()))){
        status = false;
    }
    return {
        status: status, // or false
        message: '请填写正确的手机号'
    };
}

checkform($('#myForm'), ajaxOption);

//点选输入框时 颜色变化
$('.edit-container').on('tap',function () {
    var type = parseInt(this.getAttribute('data'));
    if(type == undefined || type == null || type == ''){
        return;
    }
    $('.edit-container').removeClass('border_color');
    $('.change'+type).addClass('border_color');

})

//获取原始窗口的高度
var originalHeight=document.documentElement.clientHeight || document.body.clientHeight;
window.onresize=function(){
    //软键盘弹起与隐藏  都会引起窗口的高度发生变化
    var  resizeHeight=document.documentElement.clientHeight || document.body.clientHeight;
    if(resizeHeight*1<originalHeight*1){ //resizeHeight<originalHeight证明窗口被挤压了
        $('.sure-submit').css('display','none');
        /*$(".mui-iframe-wrapper").css('bottom','0px');*/
    }else{
        $('.sure-submit').css('display','block');
        /*$(".mui-iframe-wrapper").css('bottom','50px');*/
    }
}


//地图相关
//计算地图全屏高度
var height = $(document).height();
$('#container').css('height',height);
var geocoder, map, circle ,marker ,info ,lat ,lng ,address ,name,center ,nearPost ,shop_center , range_height ,province,city,area = null;
var range = true; //表示配送范围
var area_info = null;
var shop_city=''

geocoder = new qq.maps.Geocoder();

init_shop();

//获取水店的
function init_shop() {
    //获取水票须知
    var success = function (res) {
        var info = res.data.info;
        var shop_area_info = info.area_info;
        var shop_area_info = shop_area_info.split(' ');
        if(!isEmpty(shop_area_info) && !isEmpty(shop_area_info[1])){
            shop_city = shop_area_info[1];
            console.log(shop_city)
        }
        shop_center = info.shop_position;
        range_height = info.send_area_radius * 1000;

        //判断手机型号
        var u = navigator.userAgent, app = navigator.appVersion;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        if (isAndroid) {
            init();
        }
        //这个是ios操作系统
        if (isIOS) {
            //小程序
            if (window.__wxjs_environment === 'miniprogram') {
                if(isEmpty(shop_center)){
                    //根据已经有的地址获取经纬度
                    //地址和经纬度之间进行转换服务
                    geocoder = new qq.maps.Geocoder({
                        //设置服务请求成功的回调函数
                        complete: function (result) {
                            lat = result.detail.location.lat;
                            lng = result.detail.location.lng;
                            shop_center = lat +',' + lng;
                            init_shop_center();
                            //若服务请求失败，则运行以下函数
                            geocoder.setError(function() {
                                mui.toast('无搜索结果');
                            });
                        },
                        //若服务请求失败，则运行以下函数
                        error: function () {
                            mui.toast('无搜索结果');
                        }
                    });
                    //如果没有经纬度 那么 按照店铺地址获取经纬度
                    geocoder.getLocation(info.area_info + info.address);
                }else {
                    init_shop_center();
                }
            } else {
                init();
            }

        }
    }

    getData(shop_info,comParams(),success);
}
var area_info_status = 0;

function init_shop_center() {
    var lat = shop_center.split(',')[0];
    var lng = shop_center.split(',')[1];

    //获取附近地址列表
    codeLatLng(lat,lng);

    center = new qq.maps.LatLng(lat, lng);
    map = new qq.maps.Map(document.getElementById("container"), {
        center:center,
        zoom: 16,
        zoomControl: false,
    });

    /*if(isEmpty(marker)){*/
    marker = new qq.maps.Marker({
        //设置Marker的位置坐标
        position: center,
        //设置显示Marker的地图
        map: map
    });


    /*}*/

    //点击地图获取点击地点的地址和坐标
    geocoder = new qq.maps.Geocoder({
        complete : function(result){
            nearPost = result.detail;
            province = nearPost.addressComponents.province;
            city = nearPost.addressComponents.city;
            area = isEmpty(nearPost.addressComponents.district)?'':nearPost.addressComponents.district;
            getAddressCode(province,city,area);

            //将附近地址渲染到对应位置
            near_addList(nearPost);
        }
    });

    //绑定单击事件添加参数
    qq.maps.event.addListener(map, 'click', function(event) {
        to_addDetail = 0;
        marker.setMap(null);
        //根据获取的经纬度 得到具体地址
        make_map(event.latLng.getLat(),event.latLng.getLng());
        var latLng = new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng());
        geocoder.getAddress(latLng);
        if(!isEmpty(geocoder)){
            //设置服务请求成功的回调函数
            geocoder.setComplete(function(result) {
                nearPost = result.detail;
                province = nearPost.addressComponents.province;
                city = nearPost.addressComponents.city;
                area = isEmpty(nearPost.addressComponents.district)?'':nearPost.addressComponents.district;
                getAddressCode(province,city,area);

                //将附近地址渲染到对应位置
                near_addList(nearPost);
            });
        }
    });

}

function init() {

    //获取用户当前地址
    var geolocation = new qq.maps.Geolocation("RHHBZ-K26W6-CPISS-ENGXG-HVCRS-QJFQT", "qds");
    var options = {timeout: 8000};
    geolocation.getLocation(showPosition, showErr, options)
    function showPosition(position) {
        province = position.province;
        city = position.city;
        area = isEmpty(position.district)?'':position.district;

        lat = position.lat;
        lng = position.lng;

        if(!isEmpty(city)){
            region = city;
        }

        //获取该定位附近地址
        codeLatLng(lat,lng);
        //详细地址
        if(!isEmpty(position.name)){
            name = position.name;
            /* $('#address').val(name);*/
        }
        area_position = lat +','+lng;
        /*$('#area_position').val(lat+','+lng);*/
        //拿到经纬度并定位
        center = new qq.maps.LatLng(lat, lng);
        map = new qq.maps.Map(document.getElementById("container"), {
            center: center,
            zoom: 16,
            zoomControl: false,
        });

        marker = new qq.maps.Marker({
            //设置Marker的位置坐标
            position: center,
            //设置显示Marker的地图
            map: map
        });
        //设置Marker是否可以被拖拽，为true时可拖拽，false时不可拖拽，默认属性为false
        marker.setDraggable(false);

        if(!isEmpty(shop_center) && !isEmpty(range_height) && range_height >0){
            //判断该定位是否在配送范围
            rangeLatLng(center);
        }

        getAddressCode(province,city,area);

        //点击地图获取点击地点的地址和坐标
        geocoder = new qq.maps.Geocoder({
            complete : function(result){
                nearPost = result.detail;
                province = nearPost.addressComponents.province;
                city = nearPost.addressComponents.city;
                area = isEmpty(nearPost.addressComponents.district)?'':nearPost.addressComponents.district;
                getAddressCode(province,city,area);
                //将附近地址渲染到对应位置
                near_addList(nearPost);
            }
        });

        //绑定单击事件添加参数
        qq.maps.event.addListener(map, 'click', function(event) {
            to_addDetail = 0;
            marker.setMap(null);
            //根据获取的经纬度 得到具体地址
            make_map(event.latLng.getLat(),event.latLng.getLng());
            var latLng = new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng());
            geocoder.getAddress(latLng);

            if(!isEmpty(geocoder)){
                //设置服务请求成功的回调函数
                geocoder.setComplete(function(result) {
                    nearPost = result.detail;
                    //将附近地址渲染到对应位置
                    near_addList(nearPost);

                    province = nearPost.addressComponents.province;
                    city = nearPost.addressComponents.city;
                    area = isEmpty(nearPost.addressComponents.district)?'':nearPost.addressComponents.district;
                    getAddressCode(province,city,area);

                });
            }
        });
    };

    //定位失败直接调地图
    function showErr() {
        if(isEmpty(shop_center)){
            //根据已经有的地址获取经纬度
            //地址和经纬度之间进行转换服务
            geocoder = new qq.maps.Geocoder({
                //设置服务请求成功的回调函数
                complete: function (result) {
                    lat = result.detail.location.lat;
                    lng = result.detail.location.lng;
                    shop_center = lat +',' + lng;
                    init_shop_center();
                    //若服务请求失败，则运行以下函数
                    geocoder.setError(function() {
                        mui.toast('无搜索结果');
                    });
                },
                //若服务请求失败，则运行以下函数
                error: function () {
                    mui.toast('无搜索结果');
                }
            });
            //如果没有经纬度 那么 按照店铺地址获取经纬度
            geocoder.getLocation(info.area_info + info.address);
        }else {
            init_shop_center();
        }
    };
}

function make_map(lat,lng) {
    center = new qq.maps.LatLng(lat, lng);
    map.setCenter(center);
    marker = new qq.maps.Marker({
        map:map,
        position: center
    });
}

function codeLatLng(lat,lng) {
    //获取输入框的经纬度
    var latLng = new qq.maps.LatLng(lat, lng);
    //对指定经纬度进行解析
    geocoder.getAddress(latLng);
    //设置服务请求成功的回调函数
    geocoder.setComplete(function(result) {
        nearPost = result.detail;
        //将附近地址渲染到对应位置
        near_addList(nearPost);
    });
    //若服务请求失败，则运行以下函数
    geocoder.setError(function() {
        return null;
    });
}

function near_addList(near_post) {
    var html = template('choose-content',near_post);
    $('#choose').html(html);
    var list = near_post.nearPois;
    //选择所需的详情地址
    $('.address-choose').bind('click',function (e) {
        to_addDetail = 1;
        marker.setMap(null);
        /*info.setMap(null);*/
        var index = parseInt(this.getAttribute('data-index'));
        lat = list[index].latLng.lat;
        lng = list[index].latLng.lng;
        var user_add = list[index].latLng;
        if(!isEmpty(shop_center) && !isEmpty(range_height) && range_height >0){
            //判断是否在配送范围
            rangeLatLng(user_add);
        }

        //获取省市区
        var provice = near_post.addressComponents.province;
        var city = near_post.addressComponents.city;
        var district = isEmpty(near_post.addressComponents.district)?'':near_post.addressComponents.district;
        getAddressCode(provice ,city ,district);

        if(!$('#address-choose'+index).hasClass('active')){
            $('.address-choose').removeClass('active');
            $('#address-choose'+index).addClass('active');
        }

        make_map(lat,lng);
        name = list[index].name;
        area_position = lat +',' + lng;
    })
}

//判断是否在配送范围
//user_add 表示用户所选地址即中心位置（lat，lng）
function rangeLatLng(user_add) {
    //弹出所输入坐标后对比中心坐标 看是否在配送范围
    var lat = shop_center.split(',')[0];
    var lng = shop_center.split(',')[1];
    var shop_add = new qq.maps.LatLng(lat,lng);

    var length = qq.maps.geometry.spherical.computeDistanceBetween(shop_add, user_add);
    /*if(length >range_height){
        if(area_info_status == 1){
            mui.toast('不在配送范围内');
            range_in = 0;
            $('#range_in').val(range_in);
        }
        /!* $('.add-btn').attr('disable','true');*!/
        /!*$(".add-btn").attr("disabled",'ture');*!/
    }else {
        if(area_info_status == 1) {
            mui.toast("配送范围内")
            range_in = 1;
            $('#range_in').val(range_in);
            /!*$(".add-btn").removeAttr("disabled");*!/
        }
    }*/
}

//根据省市区 获取对应编码
function getAddressCode(provice,city,area) {

    area_info = provice + ' '+ city
    if(!isEmpty(area)){
        area_info += ' '+area;
    }
    //将省市区放到对应区域
    var p_id='';
    var c_id='';
    var a_id='';
    if(isEmpty(cityData3) || cityData3.length <=0){
        return;
    }
    for(var i=0;i<cityData3.length;i++){
        var data = cityData3[i];
        if(data.text == provice){
            p_id = data.value
            $('#province_id').val(data.value);
            var children = data.children;
            if(!isEmpty(children) && children.length > 0){
                for(var j = 0;j<children.length;j++){
                    if(children[j].text == city){
                        c_id = children[j].value;
                        $('#city_id').val(children[j].value);
                        children = children[j].children;
                        if(!isEmpty(children) && children.length > 0){
                            for(var m =0;m<children.length;m++){
                                if(children[m].text == area){
                                    a_id = children[m].value;
                                    $('#area_id').val(children[m].value);
                                    break;
                                }else if(m >= children.length -1){
                                    $('#area_id').val(c_id);
                                }
                            }
                        }else {
                            $('#area_id').val(c_id);
                        }
                        break;
                    }else if(j >= children.length-1){
                        $('#city_id').val(p_id);
                        $('#area_id').val(p_id);
                    }
                }
            }else {
                $('#city_id').val(p_id);
                $('#area_id').val(p_id);
            }
            break;
        }
    }
}

function codeAddress(infos) {
    if(isEmpty(infos)){
        return;
    }
    //根据已经有的地址获取经纬度
    //地址和经纬度之间进行转换服务
    geocoder = new qq.maps.Geocoder({
        //设置服务请求成功的回调函数
        complete: function (result) {
            lat = result.detail.location.lat;
            lng = result.detail.location.lng;
            //获取输入框的经纬度
            var latLng = new qq.maps.LatLng(lat, lng);
            //对指定经纬度进行解析
            geocoder.getAddress(latLng);
            //设置服务请求成功的回调函数
            geocoder.setComplete(function(result) {
                nearPost = result.detail;
                var list = nearPost.nearPois;
                var html = template('choose-content-search',result.detail);
                $('#choose_search').html(html);
                $('.address-choose-search').bind('click',function (e) {
                    to_addDetail = 1
                    marker.setMap(null);
                    $('#search').hide();
                    $('#map').hide();
                    $('#latLng').hide();
                    $('#add').show();
                    /*near_addList(nearPost);*/
                    var index = parseInt(this.getAttribute('data-index'));
                    lat = list[index].latLng.lat;
                    lng = list[index].latLng.lng;
                    make_map(lat,lng);
                    //清空搜索页的内容
                    $('#search_address').val('');
                    $('#choose_search').html('');
                    var user_add = list[index].latLng;
                    if(!isEmpty(shop_center) && !isEmpty(range_height) && range_height >0){
                        ///判断是否在配送范围
                        var lat = shop_center.split(',')[0];
                        var lng = shop_center.split(',')[1];
                        var shop_add = new qq.maps.LatLng(lat,lng);
                        var length = qq.maps.geometry.spherical.computeDistanceBetween(shop_add, user_add);

                        /*if(length >range_height){
                            mui.toast('不在配送范围内');
                            range_in = 0;
                            $('#range_in').val(range_in);
                            /!* $('.add-btn').attr('disable','true');*!/
                            /!*$(".add-btn").attr("disabled",'ture');*!/
                        }else {
                            mui.toast("配送范围内")
                            range_in = 1;
                            $('#range_in').val(range_in);
                            /!*$(".add-btn").removeAttr("disabled");*!/
                            name = list[index].name;
                            area_position = lat+','+lng;
                        }*/
                    }else {
                        $(".add-btn").removeAttr("disabled");
                        name = list[index].name;
                        area_position = lat+','+lng;
                    }
                })
            });
            //若服务请求失败，则运行以下函数
            geocoder.setError(function() {
                var html = '<p style="margin-top: 6rem;text-align: center">无搜索结果</p>';
                $('#choose_search').html(html);
            });
        },
        //若服务请求失败，则运行以下函数
        error: function () {
            var html = '<p style="margin-top: 6rem;text-align: center">无搜索结果</p>';
            $('#choose_search').html(html);
            /*mui.toast('定位失败，请填写如 xx 省 xx 市 xx 区 xxx');*/
        }
    });
    //如果没有经纬度 那么 按照店铺地址获取经纬度
    geocoder.getLocation(infos);
}

//点击地区页面的搜索
$('.for-search').bind('click',function () {
    $('#map').hide();
    $('#search').show();
    setTimeout("$('#search_address').focus()",100);
})

//点击搜索页面的回退
$('.for-map').bind('click',function () {
    $('#map').show();
    $('#search').hide();
})

//点击地区选地址
$('#position_address').bind('click',function () {
    area_info_status = 1;
    $('#latLng').show();
    $('#map').show();
    $('#add').hide();
})

$('.toHistory').bind('click',function () {
    $('#latLng').hide();
    $('#search').hide();
    $('#add').show();
})


//选完地址，点击完成
$('.choose_end').bind('click',function () {
    if(!to_addDetail){
        mui.toast('请在地址列表选择地址');
    }else {
        $('#area_info').val(area_info);
        $('#position_address').val(name);
        $('#area_position').val(area_position);
        $('#latLng').hide();
        $('#add').show();
    }
})

search_address.addEventListener('focus',function () {
    $('.search_address').css('border-bottom','1px solid #25bdef');
})

//监听搜索输入框
/*search_address.addEventListener('change',function () {
 var infos = $('.search_address').val();
 if(!isEmpty(infos)){
 $('.img_cuo').css('display','block');
 codeAddress(infos);
 }else {
 $('.img_cuo').css('display','none')
 }
 })*/

$('#search_address').bind("input propertychange",function(event){
    var infos = $('.search_address').val();
    if(!isEmpty(infos)){
        if(isEmpty(region)){
            region = shop_city;
        }
        $('.img_cuo').css('display','block');
        var url = 'https://apis.map.qq.com/ws/place/v1/suggestion/?region='+region+'&keyword='+infos+'&output=jsonp&key=RHHBZ-K26W6-CPISS-ENGXG-HVCRS-QJFQT';
        url = encodeURI(url);
        $.ajax({
            type:"get",
            url: url,
            dataType: "JSONP",
            jsonp: 'callback',
            success: function (res) {
                var search_nearPost = res.data;
                if(!isEmpty(search_nearPost) && search_nearPost.length >0){

                    var html = template('choose-content-search',res);
                    $('#choose_search').html(html);
                    $(function(){
                        $('.address-choose-search').bind('click',function (e) {
                            var list = search_nearPost;
                            /*to_addDetail = 1*/
                            if(!isEmpty(marker)){
                                marker.setMap(null);
                            }
                            $('#search').hide();
                            $('#latLng').hide();
                            $('#add').show();
                            /*near_addList(nearPost);*/
                            var index = parseInt(this.getAttribute('data-index'));
                            lat = list[index].location.lat;
                            lng = list[index].location.lng;
                            //获取附近地址并赋值到列表中
                            codeLatLng(lat,lng);
                            area_position = lat+','+lng;
                            $('#area_position').val(area_position);
                            //将对应地址和经纬度放到hidden中
                            //获取省市区
                            var provice = list[index].province;
                            var city = list[index].city;
                            var district = isEmpty(list[index].district)?'':list[index].district;
                            getAddressCode(provice,city,district);
                            area_info = provice + ' ' + city + ' '+district;
                            $('#area_info').val(area_info);
                            name = list[index].title;
                            $('#position_address').val(name);
                            make_map(lat,lng);
                            //清空搜索页的内容
                            $('#search_address').val('');
                            $('#choose_search').html('');
                            var user_add =  new qq.maps.LatLng(lat, lng);
                            if(!isEmpty(shop_center) && !isEmpty(range_height) && range_height >0){
                                ///判断是否在配送范围
                                var lat = shop_center.split(',')[0];
                                var lng = shop_center.split(',')[1];
                                var shop_add = new qq.maps.LatLng(lat,lng);
                                var length = qq.maps.geometry.spherical.computeDistanceBetween(shop_add, user_add);

                                /*if(length >range_height){
                                    mui.toast('不在配送范围内');
                                    range_in = 0;
                                    $('#range_in').val(range_in);
                                    /!* $('.add-btn').attr('disable','true');*!/
                                    /!*$(".add-btn").attr("disabled",'ture');*!/
                                }else {
                                    mui.toast("配送范围内")
                                    range_in = 1;
                                    $('#range_in').val(range_in);
                                    /!*$(".add-btn").removeAttr("disabled");*!/
                                    name = list[index].name;
                                    area_position = lat+','+lng;
                                }*/
                            }else {
                                $(".add-btn").removeAttr("disabled");
                                name = list[index].name;
                                area_position = lat+','+lng;
                            }
                        })
                    })
                }
            },
            error: function (res,reson) {
                mui.toast('请求失败');
            }
        });
        /*codeAddress(infos);*/
    }else {
        $('.img_cuo').css('display','none')
    }
})


//修改详细地址时重新获取经纬度
/*edit_address.addEventListener('change',function () {
 var infos = $('.area_info').val();
 if(!isEmpty(infos)){
 //获取水票须知
 var success = function (res) {
 var info = res.data.info;
 console.log(info)
 shop_center = info.shop_position;
 range_height = info.send_area_radius * 1000;
 var infos_detail = $('#edit_address').val()
 codeAddress_detail(infos + infos_detail);
 }

 getData(shop_info,comParams(),success);;
 }
 })*/

/*$('#edit_address').bind("input propertychange",function(event){
    var infos = $('.area_info').val();
    if(!isEmpty(infos)){
        //获取水票须知
        var success = function (res) {
            var info = res.data.info;
            shop_center = info.shop_position;
            range_height = info.send_area_radius * 1000;
            var infos_detail = $('#edit_address').val()
            codeAddress_detail(infos + infos_detail);
        }

        getData(shop_info,comParams(),success);;
    }
})*/

$('.img_cuo').bind('click',function () {
    $('.search_address').val('');
})

function codeAddress_detail(infos) {
    if(isEmpty(infos)){
        return;
    }
    //根据已经有的地址获取经纬度
    //地址和经纬度之间进行转换服务
    geocoder = new qq.maps.Geocoder({
        //设置服务请求成功的回调函数
        complete: function (result) {
            lat = result.detail.location.lat;
            lng = result.detail.location.lng;
            if(!isEmpty(shop_center) && !isEmpty(range_height) && range_height >0){
                //判断是否在配送范围
                var lat = shop_center.split(',')[0];
                var lng = shop_center.split(',')[1];
                var shop_add = new qq.maps.LatLng(lat,lng);
                var length = qq.maps.geometry.spherical.computeDistanceBetween(shop_add, result.detail.location);

                /*if(length >range_height){
                    mui.toast('不在配送范围内');
                    range_in = 0;
                    $('#range_in').val(range_in);
                    /!*$(".add-btn").attr("disabled",'ture');*!/
                }else {
                    mui.toast('配送范围内');
                    range_in = 1;
                    $('#range_in').val(range_in);
                    /!* $(".add-btn").removeAttr("disabled");*!/
                    $('#area_position').val(lat+','+lng);

                }*/
            }else {
                $(".add-btn").removeAttr("disabled");
                $('#area_position').val(lat+','+lng);
            }

            //若服务请求失败，则运行以下函数
            geocoder.setError(function() {
                var html = '<p style="margin-top: 6rem;text-align: center">无搜索结果</p>';
                $('#choose_search').html(html);
            });
        },
        //若服务请求失败，则运行以下函数
        error: function () {
            mui.toast('无搜索结果');
            $(".add-btn").attr("disabled",'ture');
        }
    });
    //如果没有经纬度 那么 按照店铺地址获取经纬度
    geocoder.getLocation(infos);
}

//点击选择 单位还是家庭
/*$('.radio1').on('tap', function (e) {
 var data = parseInt(this.getAttribute('data'));
 if (data == 10) {
 $('.data5').show();
 choosed_type = 1;
 } else {
 $('.data5').hide();
 }
 var type = $(e.target).val();
 $('#type').val(type)
 });*/
$('.mui-radio').on('tap', function () {
    var data = parseInt(this.getAttribute('data'));
    if (data == 10) {
        $('.data5').show();
        choosed_type = 1;
    } else {
        $('.data5').hide();
    }
    var type = $('#radio'+data).val();
    $('#type').val(type)
});


function is_range_in() {
    var status = true;
    var message = '不在配送范围内,请重新选择配送地址';
    if(range_in === 0){
        status = false;
    }

    return {
        status: status, // or false
        message: message
    };
}

//当地址类型选择单位时，必填单位名称
function is_company() {
    var status = true;
    var type = $('#type').val();
    //表示选的是单位
    if(!isEmpty(type) && type === 1){
        var company_name = $('.company_name').val();
        if(isEmpty(company_name)){
            status = false;
        }
    }
    return {
        status: status, // or false
        message: '请填写单位简称'
    };
}

//判断是否选择用户类型
function is_choose() {
    var status = true;
    var type = $('#type').val();
    if(isEmpty(type) || type <= 0){
        status = false;
    }
    return {
        status: status, // or false
        message: '请选择用户类型'
    };
}
setContentH();

function setContentH() {
    var allH = $(window).height();
    var headH = $('.mui-bar').height();
    var footH = $('#button').outerHeight(true);
    var h = allH - headH - footH;
    $('#myForm').css('height',h + 'px')
}
